package demo2;
class Money {
    public double money = 12.23;
}
class Student implements Cloneable{
    public String name;
    public Money m = new Money();


    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", money=" + m +
                '}';
    }
}
public class Test {

    public static void main(String[] args) throws CloneNotSupportedException {
        Student student1 = new Student();
        student1.name = "1sds";
        Student student2 = (Student) student1.clone();
        student1.m.money = 99;
        student1.name = "ha";
        System.out.println(student1);
        System.out.println(student2);

        System.out.println(student1.m.money);
        System.out.println(student2.m.money);

    }
}
